#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;
int n,k;

int a[N],b[N];

int main() {
    cin>>n >>k;
    for (int i=1; i<=n; i++) cin >> a[i];
    for (int i=1; i<=n; i++) cin >> b[i];

    ll s1 = 0;

    for (int i=1; i<=n; i++) {
        if (b[i]) s1+=a[i];
    }

    ll s2 = 0, cur = 0;
    for (int i=1; i<=n; i++) {
        if (!b[i]) cur += a[i];
        if (i >= k && !b[i-k]) cur -= a[i-k];
        s2=max(s2, cur);
    }
    cout << s1+s2 <<endl;
    return 0;
}
